#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 2e5 + 10;
ll a[N];
void solve()
{
    ll x, y, z;
    cin >> x >> y >> z;
    ll a, b, c;
    cin >> a >> b >> c;
    int a1 = a * x, a2 = b * y, a3 = z * c;
    int max1 = max(a1, a2);
    int ans = max(max1, a3);
    cout << ans << endl;
}
int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}